package com.itheima.demo;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Demo_HashMap002 {
    public static void main(String[] args) {
        HashMap<String, Integer> map = new HashMap<>();
        map.put("张三", 23);
        map.put("王五", 25);
        map.put("李四", 24);
        map.put("张三", 23);
        map.put("大鹏", 23);
        map.put("小皮", 23);
        map.put("小黑", 23);
        //System.out.println(map);
        //method01(map);
        boolean b = map.containsKey("赵六");
        System.out.println(b);
        boolean z = map.containsKey("张三");
        System.out.println(z);
        boolean x = map.containsKey("小黑");
        System.out.println(x);
        boolean b1 = map.containsValue(25);
        System.out.println(b1);
        boolean b2 = map.containsValue(28);
        System.out.println(b2);
        Integer q = map.remove("大鹏");
        System.out.println(q);
        //method01(map);
        //method002(map);

    }

    private static void method002(HashMap<String, Integer> map) {
        Set<Map.Entry<String, Integer>> set = map.entrySet();
        for (Map.Entry<String, Integer> entry : set) {
            String key = entry.getKey();
            Integer value = entry.getValue();
            System.out.println(key+" = "+value);
        }
    }

    private static void method01(HashMap<String, Integer> map) {
        Set<String> s = map.keySet();
        for(String key : s ){
            Integer value = map.get(key);
            System.out.println(key+"\t"+value);
        }
    }
}
